# $NetBSD: Makefile,v 1.1 2014/12/09 02:39:21 makoto Exp $

DISTNAME=		felt-3.07.src
PKGNAME=		${DISTNAME:S/.src//}
CATEGORIES=		cad
MASTER_SITES=		${MASTER_SITE_SOURCEFORGE:=felt/}
#DISTFILES=		felt-3.07.src.tar.gz felt-3.07.ps.gz

MAINTAINER=		pkgsrc-users@NetBSD.org
HOMEPAGE=		http://felt.sourceforge.net/
COMMENT=		Free system for introductory level finite element analysis
LICENSE=		gnu-gpl-v2

#XTRACT_ONLY=		felt-3.07.src.tar.gz

WRKSRC=			${WRKDIR}/${PKGNAME_NOREV}
USE_X11BASE=		yes
USE_TOOLS+=		gzcat
XAW_TYPE?=		3d
# does not directly support Xaw3d
BUILDLINK_TRANSFORM+=   l:Xaw:Xaw3d
.PHONY: buildlink-Xaw3d-inc-hack
pre-configure: buildlink-Xaw3d-inc-hack

buildlink-Xaw3d-inc-hack: buildlink-directories
	cd ${BUILDLINK_DIR}/include/X11 && ln -s Xaw3d Xaw

MAKE_ENV+=		CCOPTS=${CFLAGS:M*:Q}
MAKE_ENV+=		LDOPTS=${LDFLAGS:M*:Q}
MAKE_ENV+=		SH=${SH:Q}

INSTALLATION_DIRS+=	lib/X11/app-defaults share/doc/felt share/examples/felt
INSTALLATION_DIRS+=	share/examples/felt share/doc/felt

# following part does not work well, besides seems not necessary
# SUBST_CLASSES+=		multline
# SUBST_STAGE.multline=	post-patch
# SUBST_MESSAGE.multline= Converting multiline
# SUBST_FILES.multline=	src/Patchwork/oogl.h
# SUBST_SED.multline=	-e 's/$$/\"/'

#post-extract:
#	${GZCAT} ${DISTDIR}/felt-3.05.ps.gz > ${WRKSRC}/felt.ps

post-install:
	cd ${WRKSRC} && ${INSTALL_DATA} FAQ FAQ.html README README.old	\
		COPYING CHANGELOG TODO ${DESTDIR}${PREFIX}/share/doc/felt
	${INSTALL_DATA} ${WRKSRC}/examples/* ${DESTDIR}${PREFIX}/share/examples/felt
	# rename with felt- prefix to avoid conflict with (rather famous) graphviz command
	${MV}  ${DESTDIR}${PREFIX}/bin/patchwork ${DESTDIR}${PREFIX}/bin/felt-patchwork
	${MV}  ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/patchwork.1 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/felt-patchwork.1

# uses remove_history() and history_list()
.include "../../devel/readline/buildlink3.mk"
.include "../../mk/xaw.buildlink3.mk"
.include "../../graphics/MesaLib/buildlink3.mk"
.include "../../graphics/glw/buildlink3.mk"
.include "../../graphics/glu/buildlink3.mk"

.include "../../mk/bsd.pkg.mk"
